﻿@model PagedList<View_SellerApply>
@{
    ViewBag.Title = "卖家申请列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";


    SellerApplyQueryModel paramModel = new SellerApplyQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (SellerApplyQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("sellerapplylist", "account")" method="get">
    <div class="form_query">
        <div>
            手机号：
            <input type="text" name="mobile" id="mobile" class="abc input-default" placeholder="" value="@paramModel.mobile">&nbsp;
        </div>
        <div>
            是否审核：
            <select id="is_do" name="is_do">
                <option value="-10" @(paramModel.is_do == -10 ? "selected" : "")>全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    dc.Add("0", "否");
                    dc.Add("1", "是");
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.is_do.ToString());
            </select>&nbsp;
        </div>
        <div>
            申请时间：
            <input type="text" name="beg_time" class="calendar" id="end_time_begin" value="@paramModel.beg_time.ToString(2)"> - <input type="text" name="end_time" class="calendar" id="end_time_end" value="@paramModel.end_time.ToString(2)">&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>代购编号</th>
            <th>手机号</th>
            <th>会员名称</th>
            <th>企业类型</th>
            <th>公司名称</th>
            <th>营业执照</th>
            <th>联系人</th>
            <th>性别</th>
            <th>联系人手机</th>
            <th>邮箱</th>
            <th>QQ号</th>
            <th>公司地址</th>
            <th>申请时间</th>
            <th>是否已审核</th>
            <th>审核时间</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
<tr class="@HtmlPagerHelper.TrClass(index)">
    <td>@m.replace_buyer_NO</td>
    <td>@m.account_mobile</td>
    <td>@m.member_name</td>
    <td>@m.supplier_type_name</td>
    <td>@m.company_name</td>
    <td>
        <a class="list-img" href="@ImageFileBiz.GetImg(m.company_img)" target="_blank"> <img style="width:30px;margin:1px 1px 1px 1px;" src="@ImageFileBiz.GetImg(m.company_img,"small")" /></a>
    </td>
    <td>@m.contact_name</td>
    <td>@m.sex</td>
    <td>@m.telephone</td>
    <td>@m.email</td>
    <td>@m.qq</td>
    <td>@m.company_address</td>
    <td>@m.create_time.ToString(1)</td>
    <td>
        @switch (m.is_do)
        {
            case 1:
                @:<div class="green">是</div>
                break;
            case 0:
                if (m.apply_status == 2)
                {
                    @:<div class="red">审核拒绝[@m.refuse_reson]</div>
                }
                else
                {
                    @:<div class="red">否</div>
                }
                break;
        }
    </td>
    <td>@m.do_time.ToString(1)</td>
    <td>
        @switch (m.is_do)
        {
            case 0:
                <a href="SellerApplyInfo?seq_id=@m.seq_id">查看详情</a>
                <a href="javascript:void(0);" onclick="toDo(@m.seq_id)">审核通过</a>
                <a href="javascript:void(0);" onclick="toDoRefuse(@m.seq_id,'@m.company_name')">审核拒绝</a>
                break;
        }
        @if (m.supplier_id.HasValue && m.supplier_id > 0)
        {
            <a href="@Url.Action("add","supplier",new{ id = m.supplier_id})">查看供应商</a>
        }
    </td>
</tr>
        }
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    var cancelButton =
    {
        text: '取消',
        elCls: 'button',
        handler: function () {
            this.close();
        }
    };
    reloadHandler = function () {
        window.location.reload();
    }

    function toDo(id) {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要审核通过该申请吗?',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("ToDoBySeller", "Account")";
                                parameter = { id: id };
                      $.post(url, parameter, function (result) {
                                    ShowActionResult(result, reloadHandler);
                                });
                                this.close();
                            }
                        },
              {
                            text: '取消',
                  elCls: 'button',
                  handler: function () {
                                this.close();
                            }
              }

            ]
        });
    }
</script>

<style>
    #div_Mask {
        text-align: center;
        line-height: 100px;
        font-weight: bold
    }

    #J_Form {
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,.4);
        position: absolute;
        z-index: 1000;
        top: 0;
        left: 0;
        color: #000;
    }
</style>
<div id="div_Mask" class="hide">
    <form id="J_Form">
        <table class="table table-bordered definewidth m10 " style="width:800px;margin-top:200px;background-color:#fff">
            <tr>
                <th colspan="2">
                    确定要拒绝 <info class="red" id="refuse_username"></info> 申请吗？
                </th>
            </tr>
            <tr>
                <td class="tableleft">拒绝原因</td>
                <td><textarea id="remark" style="width:80%;" maxlength="2500" cols="4"></textarea></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <button type="button" class="btn btn-primary" id="btn_saveexp">提交</button> &nbsp;&nbsp;
                    <button type="button" class="btn btn-success" id="btn_cancel">取消</button>
                </td>
            </tr>
        </table>
    </form>
</div>
<script>
    var seq_id = 0;
    function toDoRefuse(id,refusername) {
        seq_id = id;
        $("#refuse_username").text(refusername +"");
        $("#div_Mask").show();
    }
    $("#btn_cancel").click(function () {
        $("#div_Mask").hide();
    });
    $("#btn_saveexp").click(function () {
        var remark = $("#remark").val();
        if (remark == null || remark.length < 3) {
            BUI.Message.Alert("请输入拒绝原因", 'warning');
            return false;
        }

        BUI.Message.Show({
            title: '提示',
            msg: '确定要拒绝申请通过吗？',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("ToDoBySeller", "account")";
                        parameter = {
                            id: seq_id,
                            is_refused:1,
                            reson: $("#remark").val()
                        };
                        $.post(url, parameter, function (result) {
                            ShowActionResult(result, reloadHandler);
                            $("#div_Mask").hide();
                        });
                        this.close();
                    }
                },
                cancelButton
            ]
        });
    });

</script>